<?php
//This class repersents the project access details
//Provides an interface to the project access details table in the DB 
 require_once('./inc/database.php');
db_connect();


class pad  //project_access_details
{
	/***********member*************/
	public $project_id;
	public $ftp_user;
	public $ftp_pass;
	public $ftp_address;
	public $db_name;
	public $db_user;
	public $db_pass;
	public $db_address;
	public $manager_user;
	public $manager_pass;
	public $manager_address;
	public $cp_user;
	public $cp_pass;
	public $cp_address;
	
	/**************constractor*****************/
	 public function pad()
	 	{
		 	
		}
		
	/*****************method***************************/	
	public function  insert()
		{
			$stringinsert=sprintf("INSERT INTO `project_access_details`
			(`project_id`, `ftp_user`, `ftp_pass`, `ftp_address`, `db_name`, `db_user`, `db_pass`, `db_address`,
			  `manager_user`, `manager_pass`,`manager_address`, `cp_user`, `cp_pass`,`cp_address`)
			   VALUES 	
			   ($this->project_id,'$this->ftp_user','$this->ftp_pass','$this->ftp_address',
			   '$this->db_name','$this->db_user','$this->db_pass',
			   '$this->db_address','$this->manager_user','$this->manager_pass','$this->manager_address',
			   '$this->cp_user','$this->cp_pass','$this->cp_address')");
			$queryinsert=mysql_query($stringinsert) or die(mysql_error().' '.$stringinsert);
					
		}
      public function update()
		{
		   if($this->project_id!=null || $this->project_id!="")
		   	{
			 $stringupdate=sprintf("UPDATE `project_access_details` SET 
			 `ftp_user`='$this->ftp_user',
			 `ftp_pass`='$this->ftp_pass',
			 `ftp_address`='$this->ftp_address',
			 `db_name`='$this->db_name',
			 `db_user`='$this->db_user',
			 `db_pass`='$this->db_pass',
			 `db_address`='$this->db_address',
			 `manager_user`='$this->manager_user',
			 `manager_pass`='$this->manager_pass',
			 `manager_address`='$this->manager_address',
			 `cp_user`='$this->cp_user',
			 `cp_pass`='$this->cp_pass',
			 `cp_address`='$this->cp_address' 
			  WHERE `project_id`=$this->project_id
									  ");
			 $queryupdate=mysql_query($stringupdate) or die(mysql_error().' '.$stringupdate);
			 return true ;	
           	}
			return false;
			
		}
	public function getby_id($id_project)
		{
			$stringgetby_id=sprintf("SELECT * FROM `project_access_details` WHERE `project_id`= $id_project ");
			$querygetby_id=mysql_query($stringgetby_id) or die(mysql_error().' '.$stringgetby_id);
			$row=mysql_fetch_assoc($querygetby_id);
			if(mysql_affected_rows()>0)
				{
					
					 $this->project_id=$id_project;
					 $this->ftp_user=$row['ftp_user'];
					 $this->ftp_pass=$row['ftp_pass'];
					 $this->ftp_address=$row['ftp_address'];
					 $this->db_name=$row['db_name'];
					 $this->db_user=$row['db_user'];
					 $this->db_pass=$row['db_pass'];
					 $this->db_address=$row['db_address'];
					 $this->manager_user=$row['manager_user'];
					 $this->manager_pass=$row['manager_pass'];
					 $this->manager_address=$row['manager_address'];
					 $this->cp_user=$row['cp_user'];
					 $this->cp_pass=$row['cp_pass'];
					 $this->cp_address=$row['cp_address'];
				  return true;
				}
			return false;
		}
	
	
}

?>